package com.nsoft.html5npub.utils;

import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Gallery;
import android.widget.GridView;
import android.widget.AdapterView.OnItemClickListener;

@SuppressWarnings("deprecation")
public class SingleGridView extends GridView 
			implements OnItemClickListener {
	private GestureDetector gestureScanner;
	
	private Gallery parent;
	
	public void setGalleryParent(Gallery _parent){
		this.parent=_parent;
	}
	
	private GestureDetector.SimpleOnGestureListener
		simpleOnGestureListener=new GestureDetector.
						SimpleOnGestureListener(){
		public boolean onDown(MotionEvent e) {
			return false;
		}
		
		@Override
		public boolean onFling(MotionEvent e1, 
				MotionEvent e2,float velocityX, 
				float velocityY) {
			if (parent!=null)
				parent.onFling(e1,e2,velocityX,velocityY);
			return false;
		}
	};
	
	public SingleGridView(Context context,
					AttributeSet attrs) {
		super(context,attrs);
		gestureScanner=new GestureDetector(context,
					simpleOnGestureListener);
		
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent ev) {
		return gestureScanner.onTouchEvent(ev);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, 
				View arg1,int arg2,long arg3) {
		
	}
}
